{% set product_variant = hookable_metadata.context.resource %}

{% if product_variant.channelPricings|length < 1 %}
    <button class="btn disabled">
        {{ ux_icon('tabler:eye', {'class': 'icon dropdown-item-icon'}) }}
        {{ 'sylius.ui.price_history'|trans }}
    </button>
{% else %}
    <div class="dropdown">
        <button class="btn dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
            {{ 'sylius.ui.price_history'|trans }}
        </button>
        <ul class="dropdown-menu">
            {% for channel_pricing in product_variant.channelPricings %}
                {% set parameters = { 'productId': product_variant.product.id, 'variantId': product_variant.id, 'channelPricingId': channel_pricing.id } %}
                {% set url = path('sylius_admin_channel_pricing_log_entry_index', parameters) %}
                <li>
                    <a
                        class="dropdown-item{% if url is not defined %} disabled{% endif %}"
                        href="{{ url }}"
                    >
                        {{ ux_icon(action.icon|default('tabler:eye'), {'class': 'icon dropdown-item-icon'}) }}
                        <span>
                            <span class="text-nowrap">{{ channel_pricing.channelCode|sylius_channel_name }}</span>
                        </span>
                    </a>
                </li>
            {% endfor %}
        </ul>
    </div>
{% endif %}
